﻿
function GroupExists(sender, args) {
    var exists;
    $.ajax({ type: 'POST',
        contentType: 'application/json',
        url: relRootPath + '/Services/GroupServices.asmx/GroupExists',
        data: "{ 'groupName': '" + args.Value + "' }",
        dataType: 'json',
        async:false,
        success: function(result) {
            exists = result.d;
        },
        error: function(result, status) {

        }
    }
    );

    args.IsValid = !exists;
}


function OtherGroupExists(sender, args) {
    var exists;
    $.ajax({ type: 'POST',
        contentType: 'application/json',
        url: relRootPath + '/Services/GroupServices.asmx/OtherGroupExists',
        data: "{ 'groupName': '" + args.Value + "', 'thisGroupId': '"+$.query()['id']+"' }",
        dataType: 'json',
        async: false,
        success: function(result) {
            exists = result.d;
        },
        error: function(result, status) {

        }
    }
    );

    args.IsValid = !exists;
}